package prototyping.client.student.controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.UnknownHostException;

import javax.swing.JTextArea;

import dao.server.DataLoadIP;
import prototyping.client.HelpMessage;
import prototyping.client.student.model.StudentClient;
import tools.language.MentionChat;

public class HelpButtonControllerOverig implements ActionListener{

	private StudentClient studentClient;
	private JTextArea txtArea;

	public HelpButtonControllerOverig(String userName, String server, JTextArea txtArea) {
		this.txtArea = txtArea;
		studentClient = new StudentClient(server, userName);
		studentClient.start();
	}

	@Override
	public void actionPerformed(ActionEvent arg0 ) {
		String action = arg0.getActionCommand();
		
		try {
			HelpMessage hmsg;
			hmsg = new HelpMessage(studentClient.getUsername() + ": " + action + txtArea.getText());
			studentClient.sendMessage(hmsg);
			
			MentionChat.getInstance().succesMelding();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
	}
}
